home *** CD-ROM | disk | FTP | other *** search
- property firstSprite, lastSprite, offsetNum, puzzleSprite, randomLocs, solveLocs, testRects, piecesMoved, piecesSolved, onesCount, tensCount, onesSprite, tensSprite, totalMoves
- global gSection, gMoverSprite
-
- on new me
- set the puzzleSprite of me to 3
- set the onesSprite of me to 8
- set the tensSprite of me to 9
- set the firstSprite of me to 11
- set the offsetNum of me to the firstSprite of me - 1
- case gSection of
- #puzzle1:
- set the lastSprite of me to the firstSprite of me + 9
- #puzzle2:
- set the lastSprite of me to the firstSprite of me + 18
- #puzzle3:
- set the lastSprite of me to the firstSprite of me + 24
- end case
- case gSection of
- #puzzle1:
- set the piecesSolved of me to [11, 12, 14, 15, 16, 17, 18, 19, 20]
- #puzzle2:
- set the piecesSolved of me to [11, 12, 14, 15, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
- #puzzle3:
- set the piecesSolved of me to [11, 12, 14, 15, 17, 18, 20, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
- end case
- setTargets(me)
- return me
- end
-
- on startPuzzle me
- set the onesCount of me to 0
- set the tensCount of me to 0
- set the totalMoves of me to 0
- setPuppetState([the onesSprite of me, the tensSprite of me], #c, 1)
- setPuppetState([the firstSprite of me, the lastSprite of me], #c, 1)
- puppetSprite(gMoverSprite, 1)
- getSpriteLocs(me)
- set the piecesMoved of me to []
- sort(the piecesMoved of me)
- end
-
- on clearPuzzle me
- setPuppetState([the onesSprite of me, the tensSprite of me], #c, 0)
- setPuppetState([the firstSprite of me, the lastSprite of me], #c, 0)
- puppetSprite(gMoverSprite, 0)
- end
-
- on getSpriteLocs me
- set the randomLocs of me to [:]
- repeat with snum = the firstSprite of me to the lastSprite of me
- addProp(the randomLocs of me, snum, point(the locH of sprite snum, the locV of sprite snum))
- end repeat
- end
-
- on dragPiece me
- startTimer()
- set xsprite to the clickOn
- set moveMember to the member of sprite xsprite
- set offsetH to the locH of sprite xsprite - the mouseH
- set offsetV to the locV of sprite xsprite - the mouseV
- set the member of sprite gMoverSprite to moveMember
- set the loc of sprite xsprite to point(-999, -999)
- repeat while the mouseDown
- if the timer > (60 * 4) then
- PutBack(me, xsprite)
- exit
- next repeat
- end if
- set the loc of sprite gMoverSprite to point(the mouseH + offsetH, the mouseV + offsetV)
- updateStage()
- end repeat
- EvalTarget(me, xsprite)
- end
-
- on EvalTarget me, xsprite
- set vlistPos to xsprite - the offsetNum of me
- if inside(point(the mouseH, the mouseV), getAt(the testRects of me, vlistPos)) then
- setItDown(me, xsprite, vlistPos)
- else
- if rollOver(the puzzleSprite of me) then
- PutBack(me, xsprite)
- else
- if inside(the loc of sprite gMoverSprite, the rect of sprite 1) then
- LetGo(me, xsprite)
- else
- PutBack(me, xsprite)
- end if
- end if
- end if
- end
-
- on setItDown me, xsprite, vlistPos
- puppetSound("thingset")
- set the loc of sprite xsprite to getAt(the solveLocs of me, vlistPos)
- set the loc of sprite gMoverSprite to point(-999, -999)
- if getPos(the piecesMoved of me, xsprite) = 0 then
- add(the piecesMoved of me, xsprite)
- end if
- addToCounter(me)
- updateStage()
- checkifSolved(me)
- end
-
- on PutBack me, xsprite
- puppetSound("swoosh")
- set vOrigLoc to getaProp(the randomLocs of me, xsprite)
- set the loc of sprite xsprite to vOrigLoc
- set the loc of sprite gMoverSprite to point(-999, -999)
- set listPos to getPos(the piecesMoved of me, xsprite)
- if listPos <> 0 then
- deleteAt(the piecesMoved of me, listPos)
- end if
- addToCounter(me)
- updateStage()
- end
-
- on LetGo me, xsprite
- set offsetH to the locH of sprite gMoverSprite - the mouseH
- set offsetV to the locV of sprite gMoverSprite - the mouseV
- set vNewPoint to point(the mouseH + offsetH, the mouseV + offsetV)
- setProp(the randomLocs of me, xsprite, vNewPoint)
- set the loc of sprite xsprite to vNewPoint
- set the loc of sprite gMoverSprite to point(-999, -999)
- updateStage()
- end
-
- on addToCounter me
- if the onesCount of me = 9 then
- set the onesCount of me to 0
- if the tensCount of me = 9 then
- set the tensCount of me to 0
- else
- set the tensCount of me to the tensCount of me + 1
- end if
- else
- set the onesCount of me to the onesCount of me + 1
- end if
- set the totalMoves of me to the totalMoves of me + 1
- showCounter(me)
- end
-
- on showCounter me
- set the member of sprite the onesSprite of me to member ("digit" & string(the onesCount of me))
- set the member of sprite the tensSprite of me to member ("digit" & string(the tensCount of me))
- end
-
- on checkifSolved me
- if the piecesMoved of me = the piecesSolved of me then
- puppetSound("Cheering")
- end if
- end
-
- on getTotalMoves me
- return string(the totalMoves of me)
- end
-
- on setTargets me
- case gSection of
- #puzzle1:
- set the solveLocs of me to [point(211, 143), point(340, 143), point(-100, -100), point(448, 127), point(191, 242), point(320, 240), point(448, 227), point(212, 321), point(320, 322), point(428, 322)]
- set the testRects of me to [rect(128, 78, 295, 208), rect(253, 78, 427, 208), rect(-100, -100, -90, -90), rect(385, 78, 512, 176), rect(128, 175, 255, 309), rect(214, 175, 432, 311), rect(385, 143, 512, 311), rect(128, 277, 297, 366), rect(255, 279, 385, 366), rect(344, 279, 512, 366)]
- #puzzle2:
- set the solveLocs of me to [point(176, 124), point(273, 113), point(-100, -100), point(387, 124), point(467, 125), point(-100, -100), point(191, 197), point(289, 184), point(-100, -100), point(371, 185), point(450, 197), point(176, 273), point(273, 273), point(386, 262), point(466, 273), point(191, 332), point(273, 332), point(371, 331), point(466, 333)]
- set the testRects of me to [rect(128, 78, 225, 171), rect(194, 78, 353, 148), rect(-100, -100, -90, -90), rect(323, 78, 452, 171), rect(422, 78, 512, 172), rect(-100, -100, -90, -90), rect(128, 147, 255, 247), rect(223, 121, 355, 247), rect(-100, -100, -90, -90), rect(322, 147, 421, 224), rect(389, 146, 512, 248), rect(128, 223, 224, 324), rect(194, 223, 352, 324), rect(323, 200, 449, 325), rect(420, 222, 512, 325), rect(128, 299, 255, 366), rect(224, 299, 323, 366), rect(292, 297, 451, 366), rect(420, 300, 512, 366)]
- #puzzle3:
- set the solveLocs of me to [point(168, 124), point(245, 113), point(-100, -100), point(338, 124), point(418, 124), point(-100, -100), point(477, 124), point(179, 197), point(-100, -100), point(258, 185), point(325, 185), point(-100, -100), point(404, 197), point(477, 185), point(-100, -100), point(167, 273), point(245, 273), point(340, 262), point(416, 273), point(477, 261), point(179, 332), point(246, 333), point(325, 332), point(404, 333), point(465, 332)]
- set the testRects of me to [rect(128, 78, 208, 171), rect(181, 78, 310, 148), rect(-100, -100, -90, -90), rect(286, 78, 391, 171), rect(365, 78, 471, 171), rect(-100, -100, -90, -90), rect(443, 78, 512, 171), rect(128, 147, 231, 247), rect(-100, -100, -90, -90), rect(204, 123, 312, 247), rect(285, 146, 365, 224), rect(-100, -100, -90, -90), rect(340, 147, 469, 248), rect(443, 147, 512, 223), rect(-100, -100, -90, -90), rect(128, 223, 206, 324), rect(181, 222, 310, 324), rect(286, 200, 395, 325), rect(365, 222, 468, 324), rect(443, 199, 512, 324), rect(128, 299, 231, 366), rect(206, 300, 286, 366), rect(261, 299, 390, 366), rect(365, 300, 444, 366), rect(419, 299, 512, 366)]
- end case
- end
-